package net.adetech.crj.dao;

import net.adetech.crj.entity.Queue;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.List;

@Mapper
public interface QueueMapper {
    @Select("select max(update_time) from crj_queue")
    Timestamp getMaxUpdateTime();


    @Select("select * from crj_queue where queue_id = #{queueId}")
    Queue getQueueById(String queueId);

    @Insert("insert into crj_queue " +
            " (queue_id, queue_number, service_zone, service_type, identity_type, identity_number, real_name, real_name_en, state, create_time, update_time, day_id, open_id, wx_name, wx_icon_url, next_service_type, wait_person, window_name, vip_type, police_no) " +
            " values (#{queueId,jdbcType=VARCHAR}, #{queueNumber,jdbcType=VARCHAR}, #{serviceZone,jdbcType=VARCHAR}, #{serviceType,jdbcType=VARCHAR}, #{identityType,jdbcType=VARCHAR}, #{identityNumber,jdbcType=VARCHAR}, #{realName,jdbcType=VARCHAR}, #{realNameEn,jdbcType=VARCHAR}, #{state,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{dayId,jdbcType=VARCHAR}, #{openId,jdbcType=VARCHAR}, #{wxName,jdbcType=VARCHAR}, #{wxIconUrl,jdbcType=VARCHAR}, #{nextServiceType,jdbcType=VARCHAR}, #{waitPerson,jdbcType=NUMERIC}, #{windowName,jdbcType=VARCHAR}, #{vipType,jdbcType=VARCHAR}, #{policeNo,jdbcType=VARCHAR})")
    void insert(Queue queue);


    @Update("update crj_queue set police_no = #{policeNo,jdbcType=VARCHAR},state = #{state,jdbcType=VARCHAR},create_time = #{createTime,jdbcType=TIMESTAMP},update_time = #{updateTime,jdbcType=TIMESTAMP} where queue_id = #{queueId,jdbcType=VARCHAR}")
    void update(Queue queue);



    @Select("select * from crj_queue where day_id = #{dayId}")
    List<Queue> getQueueListByDayId(String dayId);
}
